package homework0303;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo1 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("one");
        System.out.println(list);

        String s=list.get(2);//get获取下标元素
        System.out.println(s);

       /* for (String a:list){
            System.out.println(a);
        }
        */
        Iterator<String> it=list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        String old=list.set(2,"nine");//替换元素
        System.out.println(list);
        System.out.println(old);

        String b=list.remove(3);
        System.out.println(list);
        System.out.println(b);

        list.add(3,"ten");//插入元素
        System.out.println(list);











    }
}
